﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BesAsm.MasterData.Entities;
using BesAsm.MasterData.Services;

namespace BesAsm.MasterData.CommonControls
{
  /// <summary>
  /// Contains a Link object and provides lightweight access to link connectivity information  
  /// </summary>
  public class LinkInfo
  {
    private Link _link;
    private Node _usNode, _dsNode;

    public static readonly string LinkCaption = "Link Name";
    public static readonly string UsNodeCaption = "US Node";
    public static readonly string DsNodeCaption = "DS Node";

    /// <summary>
    /// Constructs a new LinkInfo
    /// </summary>
    /// <param name="link">A Link object</param>
    public LinkInfo(Link link)
    {
      _link = link;

      NodeService ns = new NodeService();
      
      _usNode = ns.GetByNodeId(_link.UsNodeId);
      _dsNode = ns.GetByNodeId(_link.DsNodeId);
    }

    /// <summary>
    /// Returns the underlying Link object's LinkName
    /// </summary>
    public string LinkName
    {
      get { return _link.LinkName; }
    }

    /// <summary>
    /// Returns the underlying Link object's upstream node NodeName
    /// </summary>
    public string UsNodeName
    {
      get { return _usNode.NodeName; }
    }

    /// <summary>
    /// Returns the underlying Link object's downstream node NodeName
    /// </summary>
    public string DsNodeName
    {
      get { return _dsNode.NodeName; }
    }

    /// <summary>
    /// Returns the underlying Link object
    /// </summary>
    public Link Link
    {
      get { return _link; }
    }


  }
}
